]> git.neil.brown.name Git - wiggle.git/commit
merge: fix a problem with unmatchable hunks.
authorNeilBrown <neil@brown.name>
Sat, 3 Oct 2020 09:30:34 +0000 (19:30 +1000)
committerNeilBrown <neil@brown.name>
Sat, 3 Oct 2020 09:30:34 +0000 (19:30 +1000)
commit2a74063c4ef6993c2fac138508680ab5625f1bac
treef5eb7b549eee83e4eee7a983b0d4843fd9ec8174
parent2802d9aa1927e133f9827716088bea3d47edeefe
merge: fix a problem with unmatchable hunks.

If the patch contains hunks that cannot be matched, wiggle cannot to
anything really useful, but sometimes it does something bad and produces
a badly formatted result.

In these cases, the hunk must get placed somewhere, and it is possible
that two hunks could line up with different places in the same line of
the original.

As wiggle normally expands conflicts to cover whole lines, to display
this coherently, you would need something like

<<<
chosen line
||||
hunk1- before
hunk2- before
===
hunk1- after
hunk2- after
>>>

But wiggle assumes that a hunk header marks the end of a conflict, so
bad things happen here.
I don't want to display the hunk header, so I think the best option is

<<<
chosen line
|||
hunk1- before
===
hunk1- after
>>>
<<<
|||
hunk2- before
===
hunk2- after
>>>

To achieve this, we don't stop collecting a conflict when we hit a
hunk-header moving forward, but when we print the conflict out, we
detect those hunk headers, and do the above.
If the final hunk doesn't actually contain any differences, don't
bother printing it.

Signed-off-by: NeilBrown <neil@brown.name>
merge2.c
tests/linux/iomap/merge
tests/linux/raid1-A/merge
tests/lustre/pool/merge [new file with mode: 0644]
tests/lustre/pool/orig [new file with mode: 0644]
tests/lustre/pool/patch [new file with mode: 0644]